import DList from "@/components/dlist";
export default {
  data() {
    return {
      order_type: 0,
      recordsData: [],
      loading: false,
      finished: false,
      page: 1,
      tabs: [{
        name: "全部",
        value: 0
      },{
        name: "商城订单",
        value: 1
      },{
        name: "非商城订单",
        value: 2
      }],
      love_name: ""
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    async getData() {
      if (this.loading === true || this.finished === true) {
        return;
      }
      this.loading = true;
      let { data, result, msg } = await $http.post("plugin.third-logistics.frontend.modules.scan.controllers.records.index", {
        page: this.page,
        order_type: this.order_type
      });
      if (result) {
        this.love_name = data.otherParams.love_name;
        this.recordsData.push(...data.page_list.data);
        if (data.page_list.data.length === 0 || data.page_list.data.length < data.page_list.per_page || data.page_list.current_page === data.page_list.last_page) {
          this.finished = true;
        }
        this.page++;
        this.isShowDirect = true;
        this.loading = false;
      } else {
        this.$toast(msg);
      }
    },
    onLoad() {
      this.getData();
    },
    onClickTab() {
      this.recordsData = [];
      this.loading = false;
      this.finished = false;
      this.page = 1;
      this.getData();
    }
  },
  components: { DList  }
};
